package com.yangxu.hospital;

import com.yangxu.hospital.common.annotation.rest.AnonymousGetMapping;
import com.yangxu.hospital.common.utils.SpringContextHolder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.ApplicationPidFileWriter;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class HospitalApplication {


    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(HospitalApplication.class);
        // 监控应用的PID，启动时可指定PID路径：--spring.pid.file=/home/aa/app.pid
        // 或者在 application.yml 添加文件路径，方便 kill，kill `cat /home/aa/app.pid`
        springApplication.addListeners(new ApplicationPidFileWriter());
        springApplication.run(args);
    }

    @Bean
    public SpringContextHolder springContextHolder() {
        return new SpringContextHolder();
    }

    /**
     * 访问首页提示
     * @return /
     */
    @AnonymousGetMapping("/")
    public String index() {
        return "Backend service started successfully";
    }
}
